Skip to content

Rework target checking for built-in attributes #145085

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

JonathanBrouwer
Copy link
Contributor

@JonathanBrouwer JonathanBrouwer commented Aug 8, 2025

This is a refactoring of target checking for built-in attributes.
This PR has the following goals:

  • Only refactor the 80% of the attributes that are simple to target check. More complicated ones like #[repr] will be in a future PR. Tho I have written the code in such a way that this will be possible to add in the future.
  • No breaking changes.
    • This part of the codebase is not very well tested though, we can do a crater run if we want to be sure.
    • I've spotted quite a few weird situations (like I don't think an impl block should be deprecated?). We can propose fixing these to in a future PR

Fixes #143780
Fixes #138510

I've split it in commits and left a description on some of the commits to help review.
r? @jdonszelmann

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Aug 8, 2025
@JonathanBrouwer JonathanBrouwer force-pushed the target_checking branch 2 times, most recently from 66feb37 to a1c6f2a Compare August 9, 2025 18:02
@rust-log-analyzer

This comment has been minimized.

@rustbot
Copy link
Collaborator

rustbot commented Aug 9, 2025

jdonszelmann is currently at their maximum review capacity.
They may take a while to respond.

@JonathanBrouwer JonathanBrouwer marked this pull request as ready for review August 9, 2025 19:06
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 9, 2025
@rustbot
Copy link
Collaborator

rustbot commented Aug 9, 2025

These commits modify the Cargo.lock file. Unintentional changes to Cargo.lock can be introduced when switching branches and rebasing PRs.

If this was unintentional then you should revert the changes before this PR is merged.
Otherwise, you can ignore this comment.

This PR modifies tests/ui/issues/. If this PR is adding new tests to tests/ui/issues/,
please refrain from doing so, and instead add it to more descriptive subdirectories.

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann

Some changes occurred in compiler/rustc_passes/src/check_attr.rs

cc @jdonszelmann

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rustbot
Copy link
Collaborator

rustbot commented Aug 10, 2025

This PR changes a file inside tests/crashes. If a crash was fixed, please move into the corresponding ui subdir and add 'Fixes #' to the PR description to autoclose the issue upon merge.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@Zalathar
Copy link
Contributor

If a PR is hard to merge due to repeated bitrot, we can always resort to a priority boost.

@jdonszelmann
Copy link
Contributor

ok, sounds good. Let's merge this ASAP with some p then? Then it merges before that rollup. I'll preemptively remake the rollup without the conflicting pr

@bors r+ rollup=never p=1

@bors
Copy link
Collaborator

bors commented Aug 13, 2025

📌 Commit 7a85aa9 has been approved by jdonszelmann

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 13, 2025
bors added a commit that referenced this pull request Aug 13, 2025
Rework target checking for built-in attributes

This is a refactoring of target checking for built-in attributes.
This PR has the following goals:
- Only refactor the 80% of the attributes that are simple to target check. More complicated ones like `#[repr]` will be in a future PR. Tho I have written the code in such a way that this will be possible to add in the future.
- No breaking changes.
  - This part of the codebase is not very well tested though, we can do a crater run if we want to be sure.
  - I've spotted quite a few weird situations (like I don't think an impl block should be deprecated?). We can propose fixing these to  in a future PR

Fixes #143780
Fixes #138510

I've split it in commits and left a description on some of the commits to help review.
r? `@jdonszelmann`
@bors
Copy link
Collaborator

bors commented Aug 13, 2025

⌛ Testing commit 7a85aa9 with merge 5477855...

@bors
Copy link
Collaborator

bors commented Aug 13, 2025

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Aug 13, 2025
@jdonszelmann
Copy link
Contributor

@bors r+

spurious failure

@bors
Copy link
Collaborator

bors commented Aug 13, 2025

💡 This pull request was already approved, no need to approve it again.

  • This pull request previously failed. You should add more commits to fix the bug, or use retry to trigger a build again.
  • There's another pull request that is currently being tested, blocking this pull request: Rollup of 9 pull requests #145351

@bors
Copy link
Collaborator

bors commented Aug 13, 2025

📌 Commit 7a85aa9 has been approved by jdonszelmann

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 13, 2025
@rust-log-analyzer

This comment has been minimized.

bors added a commit that referenced this pull request Aug 13, 2025
Rework target checking for built-in attributes

This is a refactoring of target checking for built-in attributes.
This PR has the following goals:
- Only refactor the 80% of the attributes that are simple to target check. More complicated ones like `#[repr]` will be in a future PR. Tho I have written the code in such a way that this will be possible to add in the future.
- No breaking changes.
  - This part of the codebase is not very well tested though, we can do a crater run if we want to be sure.
  - I've spotted quite a few weird situations (like I don't think an impl block should be deprecated?). We can propose fixing these to  in a future PR

Fixes #143780
Fixes #138510

I've split it in commits and left a description on some of the commits to help review.
r? `@jdonszelmann`
@bors
Copy link
Collaborator

bors commented Aug 13, 2025

⌛ Testing commit 7a85aa9 with merge 85f0a70...

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Aug 13, 2025

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Aug 13, 2025
- Added a few more variants which are needed for various attributes
- Previously a trait method with default block had the same target representation as a method in a `impl trait for` block, this has been changed (See `MethodKind`)
- Added `plural_name` for more precision on the form of the name
Every acceptor gets an `ALLOWED_TARGETS` specification which can specify per target whether it is allowed, warned, or errored.
Signed-off-by: Jonathan Brouwer <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Parsed attributes applied to where bounds ICE the compiler ICE: can't get the span of an arbitrary parsed attribute: Parsed(Repr([(ReprEmpty..
9 participants